package com.flipdf2.serialize.ppml.element;

import org.jdom.Element;
import org.jdom.Namespace;

import com.flipdf2.serialize.ppml.PPMLException;

public class PPMLTransform {
	public static final String NAME = "TRANSFORM";

	private double[] martrix;

	public Element toXML(Namespace defaultNamespace) {
		Element root = null;
		if (defaultNamespace != null) {
			root = new Element(NAME, defaultNamespace);
		} else {
			root = new Element(NAME);	
		}

		if (martrix != null && martrix.length == 6) {
			root.setAttribute("Matrix", martrix[0] + " " + martrix[1] + " " + martrix[2] + " "
					+ martrix[3] + " " + martrix[4] + " " + martrix[5]);
		}

		return root;
	}

	public void check() throws PPMLException {
		if (martrix == null) {
			throw PPMLException.getInstance(PPMLException.REQUIRED_ATTRIBUTE_LOST, "Martrix");
		}
	}
	
	public double[] getMartrix() {
		return martrix;
	}

	public void setMartrix(double[] martrix) {
		this.martrix = martrix;
	}
}
